package demo4;

public class Computer {
    public void open(){
        System.out.println("打开");
    }

    public void close(){
        System.out.println("关闭");
    }

    public void use(USB usb){
        usb.open();
        usb.close();

        if(usb instanceof KeyBoard){
            /*KeyBoard keyBoard = (KeyBoard) usb;*/
            ((KeyBoard) usb).input();
        }else if(usb instanceof Mouse){
            ((Mouse) usb).click();
        }

    }

    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.use(new KeyBoard());
        computer.use(new Mouse());
    }
}
